package com.api.main;

import com.alibaba.csp.sentinel.cluster.ClusterStateManager;
import com.alibaba.csp.sentinel.cluster.client.config.ClusterClientAssignConfig;
import com.alibaba.csp.sentinel.cluster.client.config.ClusterClientConfig;
import com.alibaba.csp.sentinel.cluster.client.config.ClusterClientConfigManager;
import com.alibaba.csp.sentinel.property.DynamicSentinelProperty;
import com.common.web.annotation.EnableGlobalWeb;
import com.element.security.single.annotation.EnableGlobalSecurity;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @auther zhangwj
 * @date 2020/4/23 9:32 上午
 */
@EnableGlobalWeb
@EnableGlobalSecurity
@SpringBootApplication
public class ApiSpringApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiSpringApplication.class, args);
        DynamicSentinelProperty<ClusterClientAssignConfig> serverAssignProperty = new DynamicSentinelProperty<>(new ClusterClientAssignConfig("127.0.0.1", 18270));
        ClusterClientConfigManager.registerServerAssignProperty(serverAssignProperty);
        ClusterClientConfig clusterClientConfig = new ClusterClientConfig();
        clusterClientConfig.setRequestTimeout(5000);
        DynamicSentinelProperty<ClusterClientConfig> clientConfigProperty = new DynamicSentinelProperty<>(clusterClientConfig);
        ClusterClientConfigManager.registerClientConfigProperty(clientConfigProperty);
        ClusterStateManager.applyState(ClusterStateManager.CLUSTER_CLIENT);
    }

}
